package com.csxh.web.pager.dao;

import java.util.ArrayList;
import java.util.List;

import com.csxh.web.util.JdbcUtil;
import com.csxh.web.util.LoggerUtil;

/**
 * 数据访问类
 * @author Administrator
 *
 */
public class PagerDao {

	public <T> long totalCountOf(Class<T> clazz, String whereCalse, Object... params) {
		long l=0;
		try {
			JdbcUtil.openConnection();
			l=JdbcUtil.countOf(clazz, whereCalse, params);
		} catch (Exception e) {

		} finally {
			JdbcUtil.closeConnection();
		}
		return l;
	}

	//根据指定条件获取分页数据
	public <T>  List<T> findPagerDataList(Class<T> clazz, long offset, int count, String whereCalse, Object... params) {
		List<T> list=new ArrayList<T>();
		try {
			JdbcUtil.openConnection();
			list=JdbcUtil.selectAll(clazz,offset, count, whereCalse, params);
		} catch (Exception e) {
          System.out.println(e.getMessage());
		} finally {
			JdbcUtil.closeConnection();
		}
		return list;
	}
	
	//无条件获取分页数据
	public <T>  List<T> findPagerDataList(Class<T> clazz, long offset, int count) {
		return findPagerDataList(clazz, offset, count,null);
	}

}
